package com.black.quick.utils;

import org.apache.commons.codec.digest.DigestUtils;

/**
 * @author shy_black
 * @date 2019/7/24 12:40
 * @Description:
 */
public class MD5Util {

    private static final String salt = "1a2b3c4d";
    private static final String saltDB = "1a2b3c4d";


    public static String md5(String src) {
        return DigestUtils.md5Hex(src);
    }

    public static String inputPassToFormPass(String inputPass)  {
        String str = "" + salt.charAt(0) + salt.charAt(2) + inputPass + salt.charAt(5) + salt.charAt(4);
        //System.out.println(str);
        return md5(str);
    }

    public static String formPassToDBPass(String fromPass,String saltDB) {
        String str = "" + saltDB.charAt(0) + saltDB.charAt(2) + fromPass + saltDB.charAt(5) + saltDB.charAt(4);
        return md5(str);
    }

    public static String inputPassToDBPass(String inputPass,String saltDB) {
        String formPass = inputPassToFormPass(inputPass);
        String DBPass = formPassToDBPass(formPass,saltDB);
        return DBPass;
    }

    public static void main(String[] args) {
//        String form = inputPassToFormPass("123456");
//        String DB = formPassToDBPass("from",saltDB);

        String DBPass = inputPassToDBPass("123456",saltDB);

       // System.out.println(form);
        System.out.println( "DBPass = " + DBPass);
    }
}


